package com.retail.shop.service.impl;


import com.retail.shop.entity.vo.ShopCardVo;
import com.retail.core.entity.ParamReq;
import com.retail.shop.entity.request.ShopCardRequest;
import com.retail.shop.mapper.ShopCardMapper;
import com.retail.shop.service.ShopCardService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
* 权益卡项 Service impl
* @author Administrator
*/
@Service
public class ShopCardServiceImpl implements ShopCardService {

   @Resource
   private ShopCardMapper shopCardMapper;

   @Override
   public ShopCardVo getModel(Long id) {
      return  shopCardMapper.getModel(id);
   }

   @Transactional
   @Override
   public Long save(ShopCardRequest shopCardRequest) {
      shopCardMapper.save(shopCardRequest);
      return shopCardRequest.getId();
   }

   @Transactional
   @Override
   public Long update(ShopCardRequest shopCardRequest) {
      shopCardMapper.update(shopCardRequest);
      return shopCardRequest.getId();
   }

   @Override
   public List<ShopCardVo> listPage(ParamReq<ShopCardRequest> params) {
      params.setStartIndex((params.getCurrent() -1 ) * params.getSize());
      return shopCardMapper.listPage(params);
   }

   @Override
   public Integer countPage(ParamReq<ShopCardRequest> params) {
       return shopCardMapper.countPage(params);
   }

   @Override
   public Integer updateDelFlagById(Long id, Integer delFlag) {
       return shopCardMapper.updateDelFlagById(id, delFlag);
   }

    @Override
    public List<ShopCardVo> shopAllCards() {
      return shopCardMapper.shopAllCards();
    }
}
